<template>
  <view class="app bg-white">
    <image
      class="w-full"
      mode="widthFix"
      @click="gotoGoodsDetail()"
      src="https://assets.miaodao.qichangsheng.com/154bb5da7b7e62bdb6f97938e0512ad2.jpg"
    />
  </view>
</template>

<script lang="ts" setup>
  import { nav } from '@/utils/homer';
  import { getGoodsDetail } from '@/api/goods';
  import { report } from '@/utils/exception';

  const level = 4;
  let goodsId = 0;

  getGoodsDetail({ level: level })
    .then((res) => {
      goodsId = res.data.id;
    })
    .catch((err) => {
      report(err);
    });

  const gotoGoodsDetail = () => {
    if (goodsId == 0) return;
    nav.jump('/pages/goods/detail?id=' + goodsId);
  };
</script>
